# -*- coding: utf-8 -*-

class Foo:
    # 封装一下 对内不对外
    __instance = None
    def __init__(self, name):
        self.name = name
    @classmethod
    def get_name(cls):  # cls是Foo这个类，绑定类方法
        if cls.__instance is None:
            cls.__instance = cls('小明') # 完成Foo类的初始化
        return cls.__instance

obj1 = Foo.get_name()
obj2 = Foo.get_name()
print(obj1 == obj2)     # true